package edu.mercer.sse.bkp;

import java.util.logging.Level;

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableMultimap;

/**
 * Configuration constants, defaults, and allowed values for application 
 * properties.<p> 
 *
 * @see #attrs
 */

public interface ConfigurationConstants 
{
	final String SETTINGS_FILE = "bkp.ini";

	final String HELP = 					
			"Specify path to be compressed, usage examples: \n" +
			"Compress.jar /home/myfolder\n" +
			"Compress.jar /home/myfolder /pub/anotherfolder\n" +
			"Compress.jar /home/myfolder --verbose\n" +
			"Compress.jar /home/largefile.txt\n" +
			"Compress.jar /home/largefile.txt /pub/file2.pdf\n";
	
	/**
	 * Properties as named in code and their corresponding 'ini' file 
	 * parameter key names, default values.<p>
	 * 
	 * Note additional abstraction: names used in ini file are not used in
	 * code as literals/keys.
	 * 
	 * <ul>
	 * <li>SNAPPY-TEST-FILE - Test file with known compression %, size hard
	 * 	coded into JUnit test.<p>&nbsp;                                              
	 *  
	 * <li>SNAPPY-TEST-FILE-LARGE-1 - Large text file or other well suited to
	 * 	Snappy compression.                                        
	 * 
	 * <li>SNAPPY-TEST-FILE-LARGE-2 - ''
	 * 
	 * <li>SNAPPY-TEST-FILE-LARGE-3 - ''<p>&nbsp;
	 * 
	 * <li>LOG-FILE - Created with each run. Contains all logging messages, 
	 * 	errors, stack-traces.<p>&nbsp;
	 * 
	 * <li>PROGRESS-METER-WIDTH - Character based progress meter width for
	 * 	individual files; doubled for overall completion when using 
	 * 	CommandComposite.<p>&nbsp;
	 * 
	 * <li>LOG-LEVEL - Java Logging Level as String: 
	 * 		<ul>
	 * 			<li>"ALL"
	 * 			<li>"WARNING"
	 * 			<li>"SEVERE"
	 * 			<li>"OFF"
	 * 		</ul>
	 * 
	 * <li>SNAPPY-EXT - File extension used for Snappy compressed files.<p>
	 * &nbsp;
	 * 
	 * <li>TMP-FLDR - Temporary are for compress/uncompress of files; 
	 * 	recommend: ample free space, self-flushing.<p>&nbsp;
	 * 
	 * <li>SNAPPY-BUFF - Bytes used for each I/O during Snappy Compression. 
	 * 	Compression not attempted for files smaller than this value.<p>&nbsp;
	 * 
	 * <li>COMPRESS-TIMEOUT - Seconds as time limit used during certain 
	 * 	compression operations and JUnit testing.<p>&nbsp;
	 * 
	 * <li>CRASH-FILE-NAME - File name used for testing exceptions. 
	 * 	Application will die when encountering files containing this String.
	 * 
	 * <li>MAX-FILE - Bytes as file size. Files larger than this are skipped;
	 * 	compression is not attempted.<p>&nbsp;
	 * 
	 * <li>VALIDATION - Option "true" or "false" for verifying 
	 * 	SnappyCompression success by uncompressing, comparing files after 
	 * 	each file compression completes.<p>&nbsp;
	 * 
	 * <li>REMOVE-UNCOMPRESSED - Option "true" or "false" for deleting 
	 * 	uncompressed file following compression.<p>&nbsp;
	 * 
	 * <li>STARTUP-TIMEOUT - Seconds used as time limit during application 
	 * 	start. Compression operations expected before this interval has 
	 * 	elapsed.<p>&nbsp;
	 * 
	 * <li>SLOW - Milliseconds: "0", "7", "50" ... Used during 
	 * 	SnappyCompression Stream I/O to slow program execution. Used during 
	 * 	testing of progress meters for small files or fast hardware.<p>&nbsp;
	 * 
	 * </ul>
	 */

	public ImmutableMultimap<String,String> attrs =
			
			new ImmutableMultimap.Builder<String,String>()			
										  .putAll(
			"SNAPPY-TEST-FILE", "snappytest_filename", 
								"test_uncompressed.csv")
								
										  .putAll(
			"SNAPPY-TEST-FILE-LARGE-1", "snappytest_large_file1", 
								"dictionary.txt")								
								
										  .putAll(
			"SNAPPY-TEST-FILE-LARGE-2", "snappytest_large_file2", 
								"Core Java Volume I.pdf")								

										  .putAll(
			"SNAPPY-TEST-FILE-LARGE-3", "snappytest_large_file3", 
								"Core Java Volume II.pdf")																
								
										  .putAll(
			"LOG-FILE", "log", 
						"bkp")
										  .putAll(
			"PROGRESS-METER-WIDTH", "progress_meter", 
						"25")						
										  .putAll(
			"LOG-LEVEL", "loglevel", 
						 "ALL" )
										  .putAll(
			"SNAPPY-EXT", "snappy_extension", 
						  "sz")
										  .putAll(
			"TMP-FLDR", "tmp_folder",
						System.getProperty("java.io.tmpdir"))
										  .putAll(
			"SNAPPY-BUFF", "snappy_buffer",
						   "32768")
						   				  .putAll(
			"COMPRESS-TIMEOUT", "timeout_compress_file",
						   		"300")
										  .putAll(
			"CRASH-FILE-NAME", "filename_to_crash",
							   "crash-this-task")
								
						   				  .putAll(
			"MAX-FILE", "max_filesize",
						"10737418240")				
										  .putAll(
			"VALIDATION", "validate_compression",
						  "true")
										  .putAll(
			"REMOVE-UNCOMPRESSED", "delete_uncompressed",
						  "false")						
						  				  .putAll(
			"STARTUP-TIMEOUT", "startup_timeout", 
							   "10")
						  				  .putAll(
			"SLOW", "slowdown", 
							   "0")
										  .build();

	/**
	 * Logging levels permissible: loading from properties.<p> 
	 */
	
	enum logLevels
	{
		/** Logging levels permitted.<p> */
		
		_;
	
		/**
		 * Map of String - Logging Level constants
		 */
		
		public ImmutableMap<String,Level> str2Lvl = ImmutableMap.of(
				
				"ALL", Level.ALL,
				
				"WARNING", Level.WARNING,
				
				"SEVERE", Level.SEVERE,
				
				"OFF", Level.OFF );
		
		
		logLevels()
		{

		}//constructor

		
		/** Permissible levels collection of Level */
		
		public ImmutableList<Level> allowedLevels()
		{ 
			return ImmutableList.copyOf( str2Lvl.values() );
			
		}//method

		
		/** Permissible levels collection of String */
		
		public ImmutableList<String> allowedLevelsAsStr()
		{ 
			return ImmutableList.copyOf( str2Lvl.keySet() );
			
		}//method
		
				
	}//enum
	
	
}//interface
